/**
 * Created by meiguizhinian on 2018/6/22
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

//TODO：等待完成, html版没有 cc.Label，创建一个
ivy.UILabelBase = ivy.UIBase.extend({
	_className:"ivy.UILabelBase",
	setString : function(text) {
		if (this._label) {
			let mlm = ivy.MultiLanguageManager.getInstance();
			text = mlm.getString(text, ivy.MultiLanguageManager.InterpretDataType.IDT_UIData, true);
			this._label.setString(text);
		}
	},
	getString : function() {
		if (this._label) {
			return this._label.getString();
		}
		return "";
	},
	setAnchorType : function(type) {
		this._super(type);
		let rect;
		let size;
		if (!this.getParent()) {
			rect = cc.rect(this.getSrcRect());
			size = cc.size(rect.width, rect.height);
		} else {
			rect = cc.rect(this.getSrcRect());
			size = cc.size(rect.width, rect.height);
			let parent = this.getParent();
			if (parent instanceof ivy.UIBase) {
				let rect1 = parent.getSrcRect();
				if (rect1.x===0 && rect1.y===0 && rect1.width===0 && rect1.height===0) {
				} else {
					let pos22 = cc.p(rect1.x + rect1.width / 2, rect1.y + rect1.height / 2);
					rect.x -= pos22.x;
					rect.y -= pos22.y;
					rect.y = -rect.y;
					let p = ivy.Tools.ConvertPointFromGL(cc.p(rect));
					rect.x = p.x;
					rect.y = p.y;
				}
			}
		}
		this.setContentSize(size);
		if (this._label) {
			switch (type) {
				case ivy.UIBase.UIAnchorType.eAnchorLT://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT, cc.VERTICAL_TEXT_ALIGNMENT_TOP);
					this._label.setAnchorPoint(cc.p(0, 1));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x, rect.y)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorLB://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT, cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
					this._label.setAnchorPoint(cc.p(0, 0));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x, rect.y + size.height)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorRT://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_RIGHT, cc.VERTICAL_TEXT_ALIGNMENT_TOP);
					this._label.setAnchorPoint(cc.p(1, 1));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + size.width, rect.y)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorRB://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_RIGHT, cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
					this._label.setAnchorPoint(cc.p(1, 0));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + size.width, rect.y + size.height)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorHT://ok untest
					this._label.setAlignment(cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP);
					this._label.setAnchorPoint(cc.p(0.5, 1));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + size.width / 2.0, rect.y)));
					break;
				case ivy.UIBase.UIAnchorType.eANchorHB://ok untest
					this._label.setAlignment(cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
					this._label.setAnchorPoint(cc.p(0.5, 0));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + size.width / 2.0, rect.y + size.height)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorLV://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_LEFT, cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
					this._label.setAnchorPoint(cc.p(0, 0.5));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x, rect.y + size.height / 2.0)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorRV://ok
					this._label.setAlignment(cc.TEXT_ALIGNMENT_RIGHT, cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
					this._label.setAnchorPoint(cc.p(1, 0.5));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + rect.width, rect.y + size.height / 2.0)));
					break;
				case ivy.UIBase.UIAnchorType.eAnchorHV://ok
				default:
					this._label.setAlignment(cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
					this._label.setAnchorPoint(cc.p(0.5, 0.5));
					this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(rect.x + size.width / 2.0, rect.y + size.height / 2.0)));
					break;
			}
			this.setSrcPosition(this.getPosition());
		}
	},
	setFormatString : function(formatS) {
		this._formatString = formatS;
	},
	updateContent : function() {
		if (this._label) {
			this._label.updateContent();
		}
	},
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////protected:
	_label : null,
	_curString : "",
	_formatString : "",
});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ivy.UILabelTTF = ivy.UILabelBase.extend({
	_className:"ivy.UILabelTTF",
	ctor : function(formName, blockName, sourceControlData) {
		this._super(formName, blockName, sourceControlData);
		this._defaultTTFConfig = cc.ttfConfig();
		if (formName && blockName && sourceControlData) {
			this.initWith(formName, blockName, sourceControlData);
		}
	},

	initWith : function(formName, blockName, sourceControlData) {
		let uim = ivy.UIManager.getInstance();
		let aniIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgAniID);
		let actionIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgActionID);
		let seqIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgSeqID);
		let x = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.ePosX);
		let y = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.ePosY);
		let w = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eWidth);
		let h = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eHeight);
		let layerID = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eLayerID);
		this._layerIDInEditor = layerID;

		let anchorType = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_AniBox_Anchor_list]);
		let showText = uim.getControlStringDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_ShowText_string]);
		let ttfPath = uim.getControlStringDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_TTFPath_string]);
		let fontSize = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Size_int]);
		cc.assert(ttfPath.length > 0);

		let config = cc.ttfConfig();
		config.fontFilePath = ttfPath;
		config.fontSize = fontSize;
		config.distanceFieldEnabled = false;
		this._isUseSystemFont = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_UsingSystemFont_list]) === 1;

		if (this._isGlobalUseSystemFontEnable) {
			if (this._isUseSystemFont && this._globalUseSystemFont) {
				let rect = uim.getBlockRect(formName, blockName);
				this._label = cc.Label.createWithSystemFont(showText, "", fontSize, cc.size(rect.width, 0))
			} else {
				this._label = cc.Label.createWithTTF(config, showText, cc.TEXT_ALIGNMENT_LEFT);
			}
		} else {
			if (this._isUseSystemFont) {
				this._label = cc.Label.createWithSystemFont(showText, "", fontSize);
			} else {
				this._label = cc.Label.createWithTTF(config, showText, cc.TEXT_ALIGNMENT_LEFT);
			}
		}

		let colorInt = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Color_color]);
		let useBold = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Bold_list]) === 1;
		if (useBold) {
			this._label.enableBold();
		}
		let useItalics = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Italics_list]) === 1;
		if (useItalics)
			this._label.enableItalics();
		let useGlow = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Glow_list]) === 1;
		if (useGlow) {
			let glowColor = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_GlowColor_color]);
			this._label.enableGlow(ivy.Tools.getColor4BFromInt32(glowColor));
		}
		let useOutline = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Outline_list]) === 1;
		if (useOutline) {
			let outlineColor = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_OutlineColor_color]);
			let outlineSize = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_OutLineSize_int]);
			this._label.enableOutline(ivy.Tools.getColor4BFromInt32(outlineColor), outlineSize);
		}
		let useShadow = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Shadow_list]) === 1;
		if (useShadow) {
			let shadowColor = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_ShadowColor_color]);
			let shadowX = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_ShadowXOffset_int]);
			let shadowY = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_ShadowYOffset_int]);
			let shadowBlurR = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_ShadowBlurRadius_int]);
			this._label.enableShadow(ivy.Tools.getColor4BFromInt32(shadowColor), cc.size(shadowX, shadowY), shadowBlurR);//三个参数
		}
		let useStrikethough = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Strikethough_list]) === 1;
		let useUnderline = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Underline_list]) === 1;
		if (useUnderline) {
			this._label.enableUnderline();
		} else {
			if (useStrikethough) {
				this._label.enableStrikethrough();
			}
		}
		this._label.setTextColor(ivy.Tools.getColor4BFromInt32(colorInt));

		let useWrap = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_Wrap_list]) === 1;
		this._label.enableWrap(useWrap);
		if (useWrap) {
			this._label.setMaxLineWidth(w);
		}
		let additionKerningV = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_AdditionKerning_float]);
		this._label.setAdditionalKerning(additionKerningV);
		let lineSpaceV = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_LineSpace_float]);
		this._label.setLineSpacing(lineSpaceV);

		this.addChild(this._label);
		this.setLocalZOrder(layerID);
		this.setSrcRect(cc.rect(x, y, w, h));
		this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(x + w/2.0, y + h/2.0)));
		this.setSrcPosition(this.getPosition());
		this.setContentSize(cc.size(w, h));
		this.setAnchorType(anchorType);
		this._enterActionID.setValue(uim.getControlActionDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_EnterAction_action]));
		this._outActionID.setValue(uim.getControlActionDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelTTF_OutAction_action]));
		this.setUIElementName(formName, blockName);
		if (!this._isUseSystemFont)
			this._defaultTTFConfig = this._label.getTTFConfig();
		this.setString(showText);
		//////////////////////////////////////////////////////////////////////////
		//设置初始可视性 wsq-2017-3-7
		let isNotVisble = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eNotVisble);
		if (isNotVisble === 1) {
			this.setVisible(false);
		}
	},
	setString : function(text) {
		if (this._label) {
			let mlm = ivy.MultiLanguageManager.getInstance();
			text = mlm.getString(text, ivy.MultiLanguageManager.InterpretDataType.IDT_UIData, true);
			if (!this._isUseSystemFont) {
				if (this._defaultTTFConfig) {
					let newConfig = cc.ttfConfig();
					Object.assign(newConfig, this._defaultTTFConfig);
					newConfig.fontName = mlm.getCurrentLanguageFontPath(this._defaultTTFConfig.fontName);
					this._label.setTTFConfig(newConfig);
				}
			}
			this._label.setString(text);
		}
	},

	setGlobalUseSystemFontEnable : function(is) {
		ivy.UILabelTTF.prototype._isGlobalUseSystemFontEnable = is;
	},
	setGlobalUseSystemFont : function(is) {
		ivy.UILabelTTF.prototype._globalUseSystemFont = is;
	},
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////private:
	_defaultTTFConfig : null,
	_isUseSystemFont : false,
	_globalUseSystemFont : false,
	_isGlobalUseSystemFontEnable : false,
});

ivy.UILabelTTF.create = function (formName, blockName, sourceControlData) {
	return new ivy.UILabelTTF(formName, blockName, sourceControlData);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ivy.UILabelFNT = ivy.UILabelBase.extend({
	_className:"ivy.UILabelFNT",
	ctor : function(formName, blockName, sourceControlData) {
		this._super(formName, blockName, sourceControlData);
		if (formName && blockName && sourceControlData) {
			this.initWith(formName, blockName, sourceControlData);
		}
	},
	initWith : function(formName, blockName, sourceControlData) {
		let uim = ivy.UIManager.getInstance();
		let aniIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgAniID);
		let actionIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgActionID);
		let seqIDInUI = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eBgSeqID);
		let x = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.ePosX);
		let y = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.ePosY);
		let w = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eWidth);
		let h = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eHeight);
		let layerID = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eLayerID);
		this._layerIDInEditor = layerID;

		let anchorType = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Anchor_list]);
		let showText = uim.getControlStringDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_ShowText_string]);
		this._defaultFntPath = uim.getControlStringDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_FNTPath_string]);
		this._defaultFontSize = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Size_int]);
		cc.assert(this._defaultFntPath.length > 0);

		this._label = cc.Label.createWithBMFont(this._defaultFntPath, showText, cc.TEXT_ALIGNMENT_CENTER);

		let colorInt = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Color_color]);
		let useItalics = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Italics_list]) === 1;
		if (useItalics) {
			this._label.enableItalics();
		}
		let useShadow = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Shadow_list]) === 1;
		if (useShadow) {
			let shadowColor = uim.getControlColorDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_ShadowColor_color]);
			let shadowX = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_ShadowXOffset_int]);
			let shadowY = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_ShadowYOffset_int]);
			let shadowBlurR = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_ShadowBlurRadius_int]);
			this._label.enableShadow(ivy.Tools.getColor4BFromInt32(shadowColor), cc.size(shadowX, shadowY), shadowBlurR);
		}
		let useStrikethough = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Strikethough_list]) === 1;
		let useUnderline = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Underline_list]) === 1;
		if (useUnderline) {
			this._label.enableUnderline();
		} else {
			if (useStrikethough) {
				this._label.enableStrikethrough();
			}
		}
		this._label.setBMFontSize(this._defaultFontSize);
		let fontColor = ivy.Tools.getColor4BFromInt32(colorInt);
		this._label.setColor(cc.color(fontColor));
		this._label.setOpacity(fontColor.a);
		let useWrap = uim.getControlListDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_Wrap_list]) === 1;
		this._label.enableWrap(useWrap);
		if (useWrap) {
			this._label.setMaxLineWidth(w);
		}
		let additionKerningV = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_AdditionKerning_float]);
		this._label.setAdditionalKerning(additionKerningV);
		let lineSpaceV = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_LineSpace_float]);
		this._label.setLineSpacing(lineSpaceV);
		this.addChild(this._label);
		this.setLocalZOrder(layerID);
		this.setSrcRect(cc.rect(x, y, w, h));
		this.setPosition(ivy.Tools.ConvertPointToGL(cc.p(x + w / 2.0, y + h / 2.0)));
		this.setSrcPosition(this.getPosition());
		this.setContentSize(cc.size(w, h));
		this.setAnchorType(anchorType);
		this._enterActionID.setValue(uim.getControlActionDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_EnterAction_action]));
		this._outActionID.setValue(uim.getControlActionDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_OutAction_action]));
		this.setUIElementName(formName, blockName);
		let useStepTimer = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_StepChangeValueTime_int]);
		if (useStepTimer > 0) {
			this._changeMaxTime = useStepTimer;
			this._changeTimer = this._changeMaxTime;
			this._useStepChangeNumberEffect = true;
			this.scheduleUpdate();
			this._stepChangeSoundPath = uim.getControlStringDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_StepChangeSoundPath_string]);
			if (!cc.FileUtils.getInstance().isFileExist(this._stepChangeSoundPath)) {
				this._stepChangeSoundPath = "";
			}
			this._stepChangeSoundRepeatPlayByTime = uim.getControlIntDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_StepChangeSoundRepeatPlayByTime_int]);
			this._stepChangeSoundStartPitch = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_StepChangeSoundStartPitch_float]);
			this._stepChangeSoundChangePitch = uim.getControlFloatDataByFindIndex(sourceControlData.propertyDataFindIndex[ivy.DefaultSourceControlTypes.SCT_ELEMENT_LabelFNT_StepChangeSoundChangePitch_float]);
			this._currentPitch = this._stepChangeSoundStartPitch;
		}

		this.setString(showText);
		//////////////////////////////////////////////////////////////////////////
		//设置初始可视性 wsq-2017-3-7
		let isNotVisble = uim.getBlockDataByType(formName, blockName, ivy.UIManager.FormDataType.eNotVisble);
		if (isNotVisble === 1) {
			this.setVisible(false);
		}
	},

	/**
	 * setString("123")
	 * setString(123)
	 * setString(1, 2, fun)
	 */
	setString : function(stringOrMin, max, formatFunc) {
		if (!this._label) {
			return;
		}
		if (arguments.length===3) {
			//非渐进式不应使用该接口
			cc.assert(this._useStepChangeNumberEffect);
			this._startChangeV = stringOrMin;
			this._currentChangeV = this._startChangeV;
			this._endChangeV = max;
			this._changeTimer = 0;
			this._stepChangeFormatFunc = formatFunc;
			if (this._endChangeV < this._startChangeV) {
				this._stepChangeDir = -1;
			} else {
				this._stepChangeDir = 1;
			}
		} else if (cc.isNumber(stringOrMin)) {
			if (this._useStepChangeNumberEffect) {
				this._stepChangeFormatFunc = null;
				this._startChangeV = parseInt(this._label.getString());
				this._currentChangeV = this._startChangeV;
				this._endChangeV = stringOrMin;
				this._changeTimer = 0;
				if (this._endChangeV < this._startChangeV) {
					this._stepChangeDir = -1;
				} else {
					this._stepChangeDir = 1;
				}
			} else {
				this.setString(stringOrMin.toString());
			}
		} else if (cc.isString(stringOrMin)) {
			let mlm = ivy.MultiLanguageManager.getInstance();
			let showText = mlm.getString(stringOrMin, ivy.MultiLanguageManager.InterpretDataType.IDT_UIData, true);
			this._label.setBMFontFilePath(mlm.getCurrentLanguageFontPath(this._defaultFntPath));
			this._label.setBMFontSize(this._defaultFontSize);
			this._label.setString(showText);
		}

		/*
		if (!this.__background) {
			this.__background = new cc.LayerColor(cc.color(255,255,255,125));
			this.addChild(this.__background, -20);
			this.__background.ignoreAnchorPointForPosition(false);
		}
		let size = this._label.getContentSize();
		this.__background.setContentSize(size);
		this.__background.setPosition(this._label.getPosition());
		this.__background.setScale(0.5);
		*/
	},
	update : function(dt) {
		if (this._useStepChangeNumberEffect&&this._label && !this._pauseStepChange) {
			++this._changeTimer;
			let curChangeV = (this._endChangeV - this._startChangeV) / this._changeMaxTime;
			if ((this._changeTimer <= this._changeMaxTime) && (curChangeV !== 0)) {
				if (this._changeTimer === 1 && this._stepChangeSoundRepeatPlayByTime === -1 && this._stepChangeSoundPath.length > 0) {
					ivy.SoundManager.getInstance().playSound(this._stepChangeSoundPath);
				} else if (this._changeTimer%this._stepChangeSoundRepeatPlayByTime === 0 && this._stepChangeSoundPath.length > 0) {
					ivy.SoundManager.getInstance().playSound(this._stepChangeSoundPath);
					this._currentPitch += this._stepChangeSoundChangePitch;
				}
			}
			if (this._changeTimer < this._changeMaxTime) {
				this._currentChangeV += curChangeV;
				switch (this._stepChangeDir) {
					case -1:
						if (curChangeV >= 0) {
							this._changeTimer = this._changeMaxTime;
						}
						break;
					default:
						if (curChangeV <= 0) {
							this._changeTimer = this._changeMaxTime;
						}
						break;
				}
				if (this._stepChangeFormatFunc) {
					this._label.setString(this._stepChangeFormatFunc(this._currentChangeV));
				} else {
					this._label.setString(this._currentChangeV);
				}
				if (this._onStepChangeFunc) {
					this._onStepChangeFunc(curChangeV);
				}
			} else if (this._changeTimer === this._changeMaxTime) {
				if (this._stepChangeFormatFunc) {
					this._label.setString(this._stepChangeFormatFunc(this._endChangeV));
				} else {
					this._label.setString(this._endChangeV);
				}

				if (this._onStepChangeFunc) {
					this._onStepChangeFunc(curChangeV);
				}
				this._currentPitch = this._stepChangeSoundStartPitch;
			}
			if (this._changeTimer === this._changeMaxTime + this._stepChangeDelayTime) {
				if (this._onStepChangeEndFunc) {
					this._onStepChangeEndFunc();
				}
			}
		}
	},
	setOnStepChangeEndCallback : function(func, delayTime=0)	{
		this._stepChangeDelayTime = delayTime;
		this._onStepChangeEndFunc = func;
	},
	setOnStepChangeCallback : function(func) {
		this._onStepChangeFunc = func;
	},

	isStepChanging : function() {
		return this._changeTimer === this._changeMaxTime + this._stepChangeDelayTime&&this._useStepChangeNumberEffect&&this._label;
	},

	setPauseStepChange : function(pause) {
		this._pauseStepChange = pause;
	},

	isPauseStepChange : function() {
		return this._pauseStepChange;
	},
	setUseStepChange : function(use)	{
		this._useStepChangeNumberEffect = use;
	},
	getStepChangeMaxTimer : function() {
		return this._changeMaxTime;
	},
	setStepChangeMaxTimer : function(v) {
		this._changeMaxTime = v;
	},
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////private:
	_onStepChangeEndFunc : null,
	_onStepChangeFunc : null,
	_stepChangeFormatFunc : null,
	//是否开启数值渐变效果
	_useStepChangeNumberEffect : false,
	_startChangeV : 0,
	_currentChangeV : 0,
	_endChangeV : 0,
	_changeTimer : 0,
	_changeMaxTime : 0,

	_pauseStepChange : false,

	_stepChangeSoundPath : "",
	_stepChangeSoundRepeatPlayByTime : -1,
	_stepChangeDelayTime : 0,
	_stepChangeSoundStartPitch : 1.0,
	_stepChangeSoundChangePitch : 0,
	_currentPitch : 1.0,
	_stepChangeDir : 1,

	_defaultFntPath : "",
	_defaultFontSize : 12,
});

ivy.UILabelFNT.create = function (formName, blockName, sourceControlData) {
	return new ivy.UILabelFNT(formName, blockName, sourceControlData);
};